/* eslint-disable no-restricted-syntax */
// import cloudbase from '@cloudbase/js-sdk';

// export function cloudbaseApp() {
//   return cloudbase.init({
//     env: 'sgb-8gqmg7kv48722f4e',
//   });
// }
// export const db = cloudbaseApp().database()
// export function development() {
//   const env = 'prod';
//   // 依次是 诗歌本、花朵、版本控制、话语的集合名称、云存储路径、话语类型
//   let SGBDBNAME; let HDBDBNAME; let VSDBNAME; let HYDBNAME; let
//     UPLOADPATH;
//   const SHIJIDB = 'shijidb'; const HYTYPE = 'huayu-type-new'; const HDINDEXIMG = 'flower-garden-index-img'; const JINWENGDB = 'jingWenDb'; const HDIMGDBNAME = 'flower-garden-index-img'; const
//     JINGWENDB = 'jingWenDb';
//   if (env === 'prod') {
//     SGBDBNAME = 'zanmeidb-new';
//     HDBDBNAME = 'flower-garden-list';
//     VSDBNAME = 'sgb-version-control';
//     HYDBNAME = 'huayu-db-new';
//     UPLOADPATH = 'sgb/nad/';
//   } else if (env === 'dev') {
//     SGBDBNAME = 'zanmeidb-dev';
//     HDBDBNAME = 'flower-garden-list-dev';
//     VSDBNAME = 'sgb-version-control-dev';
//     HYDBNAME = 'huayu-db-new-dev';
//     UPLOADPATH = 'sgb/dev/';
//   }
//   return {
//     HDBDBNAME, SGBDBNAME, VSDBNAME, HYDBNAME, SHIJIDB, UPLOADPATH, HYTYPE, HDINDEXIMG, JINWENGDB, HDIMGDBNAME, JINGWENDB,
//   };
// }

/**
 * 上传文件
 * @param cloudPath {云端路径+文件名}
 * @param filePath {本地文件对象}
 * @returns {Promise<cloudbase.storage.ICloudbaseUploadFileResult>}
 */
export function cloudbaseUpload(cloudPath, filePath) {
  // return cloudbaseApp().uploadFile({ cloudPath, filePath });
}

export function dateFormat(date, format) {
  const o = {
    "M+": date.getMonth() + 1, // month
    "d+": date.getDate(), // day
    "h+": date.getHours(), // hour
    "m+": date.getMinutes(), // minute
    "s+": date.getSeconds(), // second
    "q+": Math.floor((date.getMonth() + 3) / 3), // quarter
    S: date.getMilliseconds(), // millisecond
  };
  if (/(y+)/.test(format)) {
    // eslint-disable-next-line no-param-reassign
    format = format.replace(RegExp.$1, `${date.getFullYear()}`.substr(4 - RegExp.$1.length));
  }
  for (const k in o) {
    if (new RegExp(`(${k})`).test(format)) {
      // eslint-disable-next-line no-param-reassign
      format = format.replace(RegExp.$1, RegExp.$1.length === 1 ? o[k] : `00${o[k]}`.substr(`${o[k]}`.length));
    }
  }
  return format;
}
